﻿@using AdverseEventReportSystem.BLL.SchedulingSystem
@{
    Layout = null;
    ScheduleCycle scheduleCycle = (ScheduleCycle)@Model;
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <meta http-equiv="Cache" content="no-cache" />
    <title>排班周期详情</title>
    <link href="~/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <link href="~/lib/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
    <link href="~/lib/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
    <link href="~/Content/css/common.css" rel="stylesheet" type="text/css" />
    <script src="~/lib/jquery/jquery-1.9.0.min.js" type="text/javascript"></script>
    <script src="~/lib/ligerUI/js/ligerui.all.js"></script>
    <script src="~/Scripts/common.js?v=@DateTime.Now.ToString("yyyyMMdd")"></script>
    <style type="text/css">
        .gridtable { width: 370px;  margin: 0px;  }
        .gridtable td { height: 30px; line-height: 30px; }
    </style>
</head>
<body>
    <form>
        <div style="margin:10px 0px;">
            <table class="gridtable">
                <tr>
                    <td style="text-align:right; width:100px;">
                        排班周期：
                    </td>
                    <td>
                        <input type="text" id="txtSchedulName" name="txtSchedulName" class="l-text" style="width:250px;" value="@scheduleCycle.TypeName" />
                    </td>
                </tr>
                <tr>
                    <td style="text-align:right; width:100px;">
                        排班排序：
                    </td>
                    <td>
                        <input type="text" id="txtSchedulSort" name="txtSchedulSort" class="l-text" style="width:250px;" typeof="number" maxlength="5" value="@scheduleCycle.Sort" />
                    </td>
                </tr>
                <tr>
                    <td style="text-align:right; width:100px;">
                        启用：
                    </td>
                    <td>
                        <input type="checkbox" id="cbxEnabled" class="l-checkbox" @(scheduleCycle.Enabled == 1 ? "checked='checked'" : "") />
                        <input type="hidden" id="hdnEnabled" name="hdnEnabled" value="@(scheduleCycle.Enabled == 1 ? 1 : 0)" />
                    </td>
                </tr>
                <tr>
                    <td colspan="2" style="text-align:center;padding-top:10px;">
                        <input id="btnSubmit" type="button" value="确定" class="l-button" />&nbsp;&nbsp;&nbsp;
                        <input id="btnClose" type="button" value="取消" class="l-button-cancel" />
                        <input type="hidden" id="hdnId" name="hdnId" value="@scheduleCycle.Id" />
                    </td>
                </tr>
                <tr></tr>
            </table>
        </div>
    </form>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#btnClose").click(function () {
                frameElement.dialog.close();
            })
            $("#cbxEnabled").click(function () {
                $("#hdnEnabled").val(($('#cbxEnabled').prop('checked')) ? 1 : 0);
            })
            $("#btnSubmit").click(function () {
                save();
            });
            $(":text[typeof=number]").keyup(function () {
                var c = $(this);
                if (/[^\d]/.test(c.val())) {
                    var num = c.val().replace(/[^\d]/g, '');
                    $(this).val(num == "" ? "" : parseInt(num));
                }
            })
            dataformInit = $("form").serializeArray();
            jsonTextInit = JSON.stringify({ dataform: dataformInit });
        });
        var dataformInit;
        var jsonTextInit;
        function save() {
            //var dataform = $("form").serializeArray();
            //var jsonText = JSON.stringify({ dataform: dataform });
            //if (jsonTextInit == jsonText && parseInt($("#hdnId").val()) > 0) {
            //    var manager1 = $.ligerDialog.waitting('保存成功...');
            //    setTimeout(function () {
            //        manager1.close();
            //        frameElement.dialog.close();
            //    }, 1000);
            //    return false;
            //}
            if (IsEmpty($("#txtSchedulSort").val())) $("#txtSchedulSort").val(1);
            if (IsEmpty($("#txtSchedulName").val())) { $.ligerDialog.error("请输入排版周期");return; }
            var arr = $("form").serializeArray();
            var obj = {};
            for (var i = 0; i < arr.length; i++) {
                obj[arr[i].name] = arr[i]['value']
            }
            $.post("/Scheduling/ScheduleCycle/Save", obj, function (data, textStatus) {
                if (textStatus == "success") {
                    var d = $.parseJSON(data);
                    if (d.Result == 1) {
                        parent.window.btnSearch.click();
                        $.ligerDialog.success("保存成功");
                        frameElement.dialog.close();
                    }
                    else if (d.Result == 0) {
                        $.ligerDialog.error(d.Body);
                    }
                    else {
                        $.ligerDialog.error("程序错误");
                    }
                } else { $.ligerDialog.error("程序错误"); }
            });
        }
    </script>
</body>
</html>